import { localRequest,request } from '@/utils';
import { data } from 'browserslist';

const localGetCourseListAPI = function(){
    return localRequest({
        url:'/stu/stuCourList.json',
        method:'GET'
    })
}

const localGetTestCheckAPI = function(){
    return localRequest({
        url:'/stu/stuTestCheck.json',
        method:'GET'
    })
}

const localGetTestItemAPI = function(){
    return localRequest({
        url:'/stu/stuTestItem.json',
        method:'GET'
    })
}

const localGetTestListAPI = function(){
    return localRequest({
        url:'/stu/stuTestList.json',
        method:'GET'
    })
}

const localGetVideoListAPI = function(){
    return localRequest({
        url:'/stu/stuVideoList.json',
        method:'GET'
    })
}

const localGetLearnConditionAPI = function(){
    return localRequest({
        url:'/stu/stuLearnCondition.json',
        method:'GET'
    })
}

const localGetAIMessageAPI = function(){
    return localRequest({
        url:'stu/stuAIMessage.json',
        method:'GET'
    })
}


const getCourseListAPI = (token)=>{
    return request({
        url:'/course',
        method:'GET',
        headers:{"Authorization": "Bearer " + token}
    })
}

const getVideoListAPI = (class_id,token)=>{
    return request({
        url:'/videos',
        method:'POST',
        data:{
            class_id
        },
        headers:{"Authorization": "Bearer " + token}
    })
}

const getVideoAPI = (data,token) => {
    return request({
        url:'/video',
        method:'POST',
        data,
        headers:{"Authorization": "Bearer " + token},
        responseType:'blob'
    })
}

const videoFinishAPI = (video_id,token)=>{
    return request({
        url:'/video_done',
        method:'POST',
        data:{
            video_id
        },
        headers:{"Authorization": "Bearer " + token}
    })
}

const getExamListAPI = (class_id,token) => {
    return request({
        url:'/tests',
        method:'POST',
        data:{
            class_id
        },
        headers:{"Authorization": "Bearer " + token}
    })
}


const getExamTestAPI = (data,token) => {
    return request({
        url:'test',
        method:'POST',
        data,
        headers:{"Authorization": "Bearer " + token}
    })
}

const getExamScoreAPI = (data,token) => {
    return request({
        url:'/testscore',
        method:'POST',
        data,
        headers:{"Authorization": "Bearer " + token}
    })
}

const getCheckListAPI = (data,token) => {
    return request({
        url:'/mistake',
        method:'POST',
        data,
        headers:{"Authorization": "Bearer " + token}
    })
}

const getSituationAPI = (class_id,token)=>{
    return request({
        url:'/situation',
        method:'POST',
        data:{
            class_id,
        },
        headers:{"Authorization": "Bearer " + token}
    })

}


const AIChatAPI = (question,token)=>{
    return request({
        url:'/ai',
        method:'POST',
        data:{
            question
        },
        headers:{"Authorization": "Bearer " + token}
    })

}

const joinCourseAPI = (class_invitecode,token)=>{
    return request({
        url:'/participate',
        method:'POST',
        data:{
            class_invitecode
        },
        headers:{"Authorization": "Bearer " + token}
    })

}

const getInfoAPI = (token) => {
    return request({
        url:'/student_message',
        method:'GET',
        headers:{"Authorization": "Bearer " + token}
    })
}

const changeInfoAPI = (data,token) => {
    return request({
        url:'/student_messageChange',
        method:'POST',
        data,
        headers:{"Authorization": "Bearer " + token}
    })
}


export {
    localGetCourseListAPI,
    localGetLearnConditionAPI,
    localGetTestCheckAPI,
    localGetTestItemAPI,
    localGetTestListAPI,
    localGetVideoListAPI,
    localGetAIMessageAPI,
    getCourseListAPI,
    getVideoListAPI,
    getVideoAPI,
    getExamListAPI,
    videoFinishAPI,
    getCheckListAPI,
    getExamScoreAPI,
    getExamTestAPI,
    getSituationAPI,
    AIChatAPI,
    joinCourseAPI,
    getInfoAPI,
    changeInfoAPI
}